{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Data_source.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "authorship_tag": "ABX9TyM0mVXV5SQK2hV7Bh2FXcE8",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/panditrahulsharma/Covd-19-Data-Visualization/blob/master/Data_source.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "42Hv4csP98rb",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "#links\n",
        "#https://github.com/CSSEGISandData/COVID-19\n",
        "#https://github.com/Pitsillides91/Python-Tutorials/blob/master/CoronaVirus/Corona%20Virus%20Project%20-%20Evolution.ipynb"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QQfM2q7Ejrmn",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "107699ac-e1b9-40e8-b24e-b43cff97b916"
      },
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/gdrive')"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Mounted at /content/gdrive\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sYP-PRZJkO6l",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 86
        },
        "outputId": "43422000-e53e-4a15-9598-e35693577312"
      },
      "source": [
        "# this creates a symbolic link so that now the path /content/gdrive/My\\ Drive/ is equal to /mydrive\n",
        "!ln -s /content/gdrive/My\\ Drive/ /mydrive\n",
        "!ls /mydrive"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "'Colab Notebooks'   food-data\t       OIDv4_ToolKit\t Untitled0.ipynb\n",
            " covd-19\t    GDToT\t       pytorch-masking\t xray\n",
            " darknet\t    mask-rcnn\t       removebg\t\t yolo.ipynb\n",
            " Detectron_ballon   Mask_RCNN-master   segmentation\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gpbsM7D3kRw6",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "97f8f60e-11be-4d83-fbaa-dcb8cbbfbaa3"
      },
      "source": [
        "cd gdrive/'My Drive'/covd-19"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/content/gdrive/My Drive/covd-19\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ytEeOa6pkXaw",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "6dcc6482-acc4-4105-97c6-a325bae492d7"
      },
      "source": [
        "ls"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\u001b[0m\u001b[01;34mCOVID-19\u001b[0m/  Data_source.ipynb\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "w3BCI5rxkkFx",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "#!git clone https://github.com/CSSEGISandData/COVID-19"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iUV93fNI-4ba",
        "colab_type": "text"
      },
      "source": [
        "***cleaning start here ***\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "PewL456a-uF_",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Packages / libraries\n",
        "import os #provides functions for interacting with the operating system\n",
        "import numpy as np \n",
        "import pandas as pd\n",
        "from matplotlib import pyplot as plt\n",
        "import seaborn as sns\n",
        "from sklearn.linear_model import LinearRegression\n",
        "from sklearn.tree import DecisionTreeClassifier\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import r2_score, explained_variance_score, mean_absolute_error, mean_squared_error\n",
        "from math import sqrt\n",
        "from datetime import datetime\n",
        "\n",
        "%matplotlib inline\n",
        "\n",
        "# To install sklearn type \"pip install numpy scipy scikit-learn\" to the anaconda terminal\n",
        "\n",
        "# To change scientific numbers to float\n",
        "np.set_printoptions(formatter={'float_kind':'{:f}'.format})\n",
        "\n",
        "# Increases the size of sns plots\n",
        "sns.set(rc={'figure.figsize':(12,10)})\n",
        "\n",
        "# import sys\n",
        "# !conda list Check the packages installed"
      ],
      "execution_count": 67,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "zkOwd5DxAJbM",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "outputId": "d9b5ceff-9a38-4097-84b5-31ce5f4809f2"
      },
      "source": [
        "ls COVID-19/csse_covid_19_data/csse_covid_19_time_series/"
      ],
      "execution_count": 68,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "time_series_covid19_confirmed.csv  time_series_covid19_recovered.csv\n",
            "time_series_covid19_deaths.csv\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "cscvuy-q-1t0",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 308
        },
        "outputId": "9155953e-83ca-4b5e-a9d2-7d914ad0fd3f"
      },
      "source": [
        "# Loading the cumulative raw data\n",
        "\n",
        "raw_data_confirmed = pd.read_csv('COVID-19/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed.csv')\n",
        "raw_data_deaths = pd.read_csv('COVID-19/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths.csv')\n",
        "raw_data_Recovered = pd.read_csv('COVID-19/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered.csv')\n",
        "\n",
        "print(\"The Shape of Cornirmed is: \", raw_data_confirmed.shape)\n",
        "print(\"The Shape of Deaths is: \", raw_data_deaths.shape)\n",
        "print(\"The Shape of Recovered is: \", raw_data_Recovered.shape)\n",
        "\n",
        "raw_data_confirmed.head()"
      ],
      "execution_count": 69,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "The Shape of Cornirmed is:  (266, 184)\n",
            "The Shape of Deaths is:  (266, 184)\n",
            "The Shape of Recovered is:  (253, 184)\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>1/22/20</th>\n",
              "      <th>1/23/20</th>\n",
              "      <th>1/24/20</th>\n",
              "      <th>1/25/20</th>\n",
              "      <th>1/26/20</th>\n",
              "      <th>1/27/20</th>\n",
              "      <th>1/28/20</th>\n",
              "      <th>1/29/20</th>\n",
              "      <th>1/30/20</th>\n",
              "      <th>1/31/20</th>\n",
              "      <th>2/1/20</th>\n",
              "      <th>2/2/20</th>\n",
              "      <th>2/3/20</th>\n",
              "      <th>2/4/20</th>\n",
              "      <th>2/5/20</th>\n",
              "      <th>2/6/20</th>\n",
              "      <th>2/7/20</th>\n",
              "      <th>2/8/20</th>\n",
              "      <th>2/9/20</th>\n",
              "      <th>2/10/20</th>\n",
              "      <th>2/11/20</th>\n",
              "      <th>2/12/20</th>\n",
              "      <th>2/13/20</th>\n",
              "      <th>2/14/20</th>\n",
              "      <th>2/15/20</th>\n",
              "      <th>2/16/20</th>\n",
              "      <th>2/17/20</th>\n",
              "      <th>2/18/20</th>\n",
              "      <th>2/19/20</th>\n",
              "      <th>2/20/20</th>\n",
              "      <th>2/21/20</th>\n",
              "      <th>2/22/20</th>\n",
              "      <th>2/23/20</th>\n",
              "      <th>2/24/20</th>\n",
              "      <th>2/25/20</th>\n",
              "      <th>2/26/20</th>\n",
              "      <th>...</th>\n",
              "      <th>6/10/20</th>\n",
              "      <th>6/11/20</th>\n",
              "      <th>6/12/20</th>\n",
              "      <th>6/13/20</th>\n",
              "      <th>6/14/20</th>\n",
              "      <th>6/15/20</th>\n",
              "      <th>6/16/20</th>\n",
              "      <th>6/17/20</th>\n",
              "      <th>6/18/20</th>\n",
              "      <th>6/19/20</th>\n",
              "      <th>6/20/20</th>\n",
              "      <th>6/21/20</th>\n",
              "      <th>6/22/20</th>\n",
              "      <th>6/23/20</th>\n",
              "      <th>6/24/20</th>\n",
              "      <th>6/25/20</th>\n",
              "      <th>6/26/20</th>\n",
              "      <th>6/27/20</th>\n",
              "      <th>6/28/20</th>\n",
              "      <th>6/29/20</th>\n",
              "      <th>6/30/20</th>\n",
              "      <th>7/1/20</th>\n",
              "      <th>7/2/20</th>\n",
              "      <th>7/3/20</th>\n",
              "      <th>7/4/20</th>\n",
              "      <th>7/5/20</th>\n",
              "      <th>7/6/20</th>\n",
              "      <th>7/7/20</th>\n",
              "      <th>7/8/20</th>\n",
              "      <th>7/9/20</th>\n",
              "      <th>7/10/20</th>\n",
              "      <th>7/11/20</th>\n",
              "      <th>7/12/20</th>\n",
              "      <th>7/13/20</th>\n",
              "      <th>7/14/20</th>\n",
              "      <th>7/15/20</th>\n",
              "      <th>7/16/20</th>\n",
              "      <th>7/17/20</th>\n",
              "      <th>7/18/20</th>\n",
              "      <th>7/19/20</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>33.93911</td>\n",
              "      <td>67.709953</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>...</td>\n",
              "      <td>22142</td>\n",
              "      <td>22890</td>\n",
              "      <td>23546</td>\n",
              "      <td>24102</td>\n",
              "      <td>24766</td>\n",
              "      <td>25527</td>\n",
              "      <td>26310</td>\n",
              "      <td>26874</td>\n",
              "      <td>27532</td>\n",
              "      <td>27878</td>\n",
              "      <td>28424</td>\n",
              "      <td>28833</td>\n",
              "      <td>29157</td>\n",
              "      <td>29481</td>\n",
              "      <td>29640</td>\n",
              "      <td>30175</td>\n",
              "      <td>30451</td>\n",
              "      <td>30616</td>\n",
              "      <td>30967</td>\n",
              "      <td>31238</td>\n",
              "      <td>31517</td>\n",
              "      <td>31836</td>\n",
              "      <td>32022</td>\n",
              "      <td>32324</td>\n",
              "      <td>32672</td>\n",
              "      <td>32951</td>\n",
              "      <td>33190</td>\n",
              "      <td>33384</td>\n",
              "      <td>33594</td>\n",
              "      <td>33908</td>\n",
              "      <td>34194</td>\n",
              "      <td>34366</td>\n",
              "      <td>34451</td>\n",
              "      <td>34455</td>\n",
              "      <td>34740</td>\n",
              "      <td>34994</td>\n",
              "      <td>35070</td>\n",
              "      <td>35229</td>\n",
              "      <td>35301</td>\n",
              "      <td>35475</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Albania</td>\n",
              "      <td>41.15330</td>\n",
              "      <td>20.168300</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>...</td>\n",
              "      <td>1341</td>\n",
              "      <td>1385</td>\n",
              "      <td>1416</td>\n",
              "      <td>1464</td>\n",
              "      <td>1521</td>\n",
              "      <td>1590</td>\n",
              "      <td>1672</td>\n",
              "      <td>1722</td>\n",
              "      <td>1788</td>\n",
              "      <td>1838</td>\n",
              "      <td>1891</td>\n",
              "      <td>1962</td>\n",
              "      <td>1995</td>\n",
              "      <td>2047</td>\n",
              "      <td>2114</td>\n",
              "      <td>2192</td>\n",
              "      <td>2269</td>\n",
              "      <td>2330</td>\n",
              "      <td>2402</td>\n",
              "      <td>2466</td>\n",
              "      <td>2535</td>\n",
              "      <td>2580</td>\n",
              "      <td>2662</td>\n",
              "      <td>2752</td>\n",
              "      <td>2819</td>\n",
              "      <td>2893</td>\n",
              "      <td>2964</td>\n",
              "      <td>3038</td>\n",
              "      <td>3106</td>\n",
              "      <td>3188</td>\n",
              "      <td>3278</td>\n",
              "      <td>3371</td>\n",
              "      <td>3454</td>\n",
              "      <td>3571</td>\n",
              "      <td>3667</td>\n",
              "      <td>3752</td>\n",
              "      <td>3851</td>\n",
              "      <td>3906</td>\n",
              "      <td>4008</td>\n",
              "      <td>4090</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Algeria</td>\n",
              "      <td>28.03390</td>\n",
              "      <td>1.659600</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>...</td>\n",
              "      <td>10484</td>\n",
              "      <td>10589</td>\n",
              "      <td>10698</td>\n",
              "      <td>10810</td>\n",
              "      <td>10919</td>\n",
              "      <td>11031</td>\n",
              "      <td>11147</td>\n",
              "      <td>11268</td>\n",
              "      <td>11385</td>\n",
              "      <td>11504</td>\n",
              "      <td>11631</td>\n",
              "      <td>11771</td>\n",
              "      <td>11920</td>\n",
              "      <td>12076</td>\n",
              "      <td>12248</td>\n",
              "      <td>12445</td>\n",
              "      <td>12685</td>\n",
              "      <td>12968</td>\n",
              "      <td>13273</td>\n",
              "      <td>13571</td>\n",
              "      <td>13907</td>\n",
              "      <td>14272</td>\n",
              "      <td>14657</td>\n",
              "      <td>15070</td>\n",
              "      <td>15500</td>\n",
              "      <td>15941</td>\n",
              "      <td>16404</td>\n",
              "      <td>16879</td>\n",
              "      <td>17348</td>\n",
              "      <td>17808</td>\n",
              "      <td>18242</td>\n",
              "      <td>18712</td>\n",
              "      <td>19195</td>\n",
              "      <td>19689</td>\n",
              "      <td>20216</td>\n",
              "      <td>20770</td>\n",
              "      <td>21355</td>\n",
              "      <td>21948</td>\n",
              "      <td>22549</td>\n",
              "      <td>23084</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Andorra</td>\n",
              "      <td>42.50630</td>\n",
              "      <td>1.521800</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>...</td>\n",
              "      <td>852</td>\n",
              "      <td>852</td>\n",
              "      <td>853</td>\n",
              "      <td>853</td>\n",
              "      <td>853</td>\n",
              "      <td>853</td>\n",
              "      <td>854</td>\n",
              "      <td>854</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>855</td>\n",
              "      <td>858</td>\n",
              "      <td>861</td>\n",
              "      <td>862</td>\n",
              "      <td>877</td>\n",
              "      <td>880</td>\n",
              "      <td>880</td>\n",
              "      <td>880</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Angola</td>\n",
              "      <td>-11.20270</td>\n",
              "      <td>17.873900</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>...</td>\n",
              "      <td>113</td>\n",
              "      <td>118</td>\n",
              "      <td>130</td>\n",
              "      <td>138</td>\n",
              "      <td>140</td>\n",
              "      <td>142</td>\n",
              "      <td>148</td>\n",
              "      <td>155</td>\n",
              "      <td>166</td>\n",
              "      <td>172</td>\n",
              "      <td>176</td>\n",
              "      <td>183</td>\n",
              "      <td>186</td>\n",
              "      <td>189</td>\n",
              "      <td>197</td>\n",
              "      <td>212</td>\n",
              "      <td>212</td>\n",
              "      <td>259</td>\n",
              "      <td>267</td>\n",
              "      <td>276</td>\n",
              "      <td>284</td>\n",
              "      <td>291</td>\n",
              "      <td>315</td>\n",
              "      <td>328</td>\n",
              "      <td>346</td>\n",
              "      <td>346</td>\n",
              "      <td>346</td>\n",
              "      <td>386</td>\n",
              "      <td>386</td>\n",
              "      <td>396</td>\n",
              "      <td>458</td>\n",
              "      <td>462</td>\n",
              "      <td>506</td>\n",
              "      <td>525</td>\n",
              "      <td>541</td>\n",
              "      <td>576</td>\n",
              "      <td>607</td>\n",
              "      <td>638</td>\n",
              "      <td>687</td>\n",
              "      <td>705</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 184 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "  Province/State Country/Region       Lat  ...  7/17/20  7/18/20  7/19/20\n",
              "0            NaN    Afghanistan  33.93911  ...    35229    35301    35475\n",
              "1            NaN        Albania  41.15330  ...     3906     4008     4090\n",
              "2            NaN        Algeria  28.03390  ...    21948    22549    23084\n",
              "3            NaN        Andorra  42.50630  ...      880      880      880\n",
              "4            NaN         Angola -11.20270  ...      638      687      705\n",
              "\n",
              "[5 rows x 184 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 69
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6rPYfQs_A4AA",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 130
        },
        "outputId": "cbc596d7-5a4c-4b40-acfa-78289c07baa2"
      },
      "source": [
        "raw_data_Recovered[raw_data_Recovered['Country/Region'] == 'US']"
      ],
      "execution_count": 70,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>1/22/20</th>\n",
              "      <th>1/23/20</th>\n",
              "      <th>1/24/20</th>\n",
              "      <th>1/25/20</th>\n",
              "      <th>1/26/20</th>\n",
              "      <th>1/27/20</th>\n",
              "      <th>1/28/20</th>\n",
              "      <th>1/29/20</th>\n",
              "      <th>1/30/20</th>\n",
              "      <th>1/31/20</th>\n",
              "      <th>2/1/20</th>\n",
              "      <th>2/2/20</th>\n",
              "      <th>2/3/20</th>\n",
              "      <th>2/4/20</th>\n",
              "      <th>2/5/20</th>\n",
              "      <th>2/6/20</th>\n",
              "      <th>2/7/20</th>\n",
              "      <th>2/8/20</th>\n",
              "      <th>2/9/20</th>\n",
              "      <th>2/10/20</th>\n",
              "      <th>2/11/20</th>\n",
              "      <th>2/12/20</th>\n",
              "      <th>2/13/20</th>\n",
              "      <th>2/14/20</th>\n",
              "      <th>2/15/20</th>\n",
              "      <th>2/16/20</th>\n",
              "      <th>2/17/20</th>\n",
              "      <th>2/18/20</th>\n",
              "      <th>2/19/20</th>\n",
              "      <th>2/20/20</th>\n",
              "      <th>2/21/20</th>\n",
              "      <th>2/22/20</th>\n",
              "      <th>2/23/20</th>\n",
              "      <th>2/24/20</th>\n",
              "      <th>2/25/20</th>\n",
              "      <th>2/26/20</th>\n",
              "      <th>...</th>\n",
              "      <th>6/10/20</th>\n",
              "      <th>6/11/20</th>\n",
              "      <th>6/12/20</th>\n",
              "      <th>6/13/20</th>\n",
              "      <th>6/14/20</th>\n",
              "      <th>6/15/20</th>\n",
              "      <th>6/16/20</th>\n",
              "      <th>6/17/20</th>\n",
              "      <th>6/18/20</th>\n",
              "      <th>6/19/20</th>\n",
              "      <th>6/20/20</th>\n",
              "      <th>6/21/20</th>\n",
              "      <th>6/22/20</th>\n",
              "      <th>6/23/20</th>\n",
              "      <th>6/24/20</th>\n",
              "      <th>6/25/20</th>\n",
              "      <th>6/26/20</th>\n",
              "      <th>6/27/20</th>\n",
              "      <th>6/28/20</th>\n",
              "      <th>6/29/20</th>\n",
              "      <th>6/30/20</th>\n",
              "      <th>7/1/20</th>\n",
              "      <th>7/2/20</th>\n",
              "      <th>7/3/20</th>\n",
              "      <th>7/4/20</th>\n",
              "      <th>7/5/20</th>\n",
              "      <th>7/6/20</th>\n",
              "      <th>7/7/20</th>\n",
              "      <th>7/8/20</th>\n",
              "      <th>7/9/20</th>\n",
              "      <th>7/10/20</th>\n",
              "      <th>7/11/20</th>\n",
              "      <th>7/12/20</th>\n",
              "      <th>7/13/20</th>\n",
              "      <th>7/14/20</th>\n",
              "      <th>7/15/20</th>\n",
              "      <th>7/16/20</th>\n",
              "      <th>7/17/20</th>\n",
              "      <th>7/18/20</th>\n",
              "      <th>7/19/20</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>225</th>\n",
              "      <td>NaN</td>\n",
              "      <td>US</td>\n",
              "      <td>40.0</td>\n",
              "      <td>-100.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>5</td>\n",
              "      <td>5</td>\n",
              "      <td>5</td>\n",
              "      <td>5</td>\n",
              "      <td>6</td>\n",
              "      <td>6</td>\n",
              "      <td>...</td>\n",
              "      <td>533504</td>\n",
              "      <td>540292</td>\n",
              "      <td>547386</td>\n",
              "      <td>556606</td>\n",
              "      <td>561816</td>\n",
              "      <td>576334</td>\n",
              "      <td>583503</td>\n",
              "      <td>592191</td>\n",
              "      <td>599115</td>\n",
              "      <td>606715</td>\n",
              "      <td>617460</td>\n",
              "      <td>622133</td>\n",
              "      <td>640198</td>\n",
              "      <td>647548</td>\n",
              "      <td>656161</td>\n",
              "      <td>663562</td>\n",
              "      <td>670809</td>\n",
              "      <td>679308</td>\n",
              "      <td>685164</td>\n",
              "      <td>705203</td>\n",
              "      <td>720631</td>\n",
              "      <td>729994</td>\n",
              "      <td>781970</td>\n",
              "      <td>790404</td>\n",
              "      <td>894325</td>\n",
              "      <td>906763</td>\n",
              "      <td>924148</td>\n",
              "      <td>936476</td>\n",
              "      <td>953462</td>\n",
              "      <td>969111</td>\n",
              "      <td>983185</td>\n",
              "      <td>995576</td>\n",
              "      <td>1006326</td>\n",
              "      <td>1031939</td>\n",
              "      <td>1049098</td>\n",
              "      <td>1075882</td>\n",
              "      <td>1090645</td>\n",
              "      <td>1107204</td>\n",
              "      <td>1122720</td>\n",
              "      <td>1131121</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>1 rows × 184 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "    Province/State Country/Region   Lat  ...  7/17/20  7/18/20  7/19/20\n",
              "225            NaN             US  40.0  ...  1107204  1122720  1131121\n",
              "\n",
              "[1 rows x 184 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 70
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BaNbBVHOBSif",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 258
        },
        "outputId": "834e2fd0-5295-41fa-f395-4cfc9f5facc1"
      },
      "source": [
        "#https://dfrieds.com/data-analysis/melt-unpivot-python-pandas.html\n",
        "\n",
        "# Un-Pivoting the data\n",
        "\n",
        "raw_data_confirmed2 = pd.melt(raw_data_confirmed, id_vars=['Province/State', 'Country/Region', 'Lat', 'Long'], var_name=['Date'])\n",
        "raw_data_deaths2 = pd.melt(raw_data_deaths, id_vars=['Province/State', 'Country/Region', 'Lat', 'Long'], var_name=['Date'])\n",
        "raw_data_Recovered2 = pd.melt(raw_data_Recovered, id_vars=['Province/State', 'Country/Region', 'Lat', 'Long'], var_name=['Date'])\n",
        "\n",
        "\n",
        "print(\"The Shape of Cornirmed is: \", raw_data_confirmed2.shape)\n",
        "print(\"The Shape of Cornirmed is: \", raw_data_deaths2.shape)\n",
        "print(\"The Shape of Cornirmed is: \", raw_data_Recovered2.shape)\n",
        "\n",
        "\n",
        "raw_data_confirmed2.head()\n",
        "\n"
      ],
      "execution_count": 71,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "The Shape of Cornirmed is:  (47880, 6)\n",
            "The Shape of Cornirmed is:  (47880, 6)\n",
            "The Shape of Cornirmed is:  (45540, 6)\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>Date</th>\n",
              "      <th>value</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>33.93911</td>\n",
              "      <td>67.709953</td>\n",
              "      <td>1/22/20</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Albania</td>\n",
              "      <td>41.15330</td>\n",
              "      <td>20.168300</td>\n",
              "      <td>1/22/20</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Algeria</td>\n",
              "      <td>28.03390</td>\n",
              "      <td>1.659600</td>\n",
              "      <td>1/22/20</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Andorra</td>\n",
              "      <td>42.50630</td>\n",
              "      <td>1.521800</td>\n",
              "      <td>1/22/20</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>NaN</td>\n",
              "      <td>Angola</td>\n",
              "      <td>-11.20270</td>\n",
              "      <td>17.873900</td>\n",
              "      <td>1/22/20</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Province/State Country/Region       Lat       Long     Date  value\n",
              "0            NaN    Afghanistan  33.93911  67.709953  1/22/20      0\n",
              "1            NaN        Albania  41.15330  20.168300  1/22/20      0\n",
              "2            NaN        Algeria  28.03390   1.659600  1/22/20      0\n",
              "3            NaN        Andorra  42.50630   1.521800  1/22/20      0\n",
              "4            NaN         Angola -11.20270  17.873900  1/22/20      0"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 71
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "YRPc35w1Qzsd",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 71,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "UGG7lNpKTRX-",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Converting the new column to dates\n",
        "\n",
        "raw_data_confirmed2['Date'] = pd.to_datetime(raw_data_confirmed2['Date'],errors='coerce')\n",
        "raw_data_deaths2['Date'] = pd.to_datetime(raw_data_deaths2['Date'],errors='coerce')\n",
        "raw_data_Recovered2['Date'] = pd.to_datetime(raw_data_Recovered2['Date'],errors='coerce')"
      ],
      "execution_count": 72,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JDHOcbDFTzXs",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Renaming the Values\n",
        "raw_data_confirmed2.columns = raw_data_confirmed2.columns.str.replace('value', 'Confirmed')\n",
        "raw_data_deaths2.columns = raw_data_deaths2.columns.str.replace('value', 'Deaths')\n",
        "raw_data_Recovered2.columns = raw_data_Recovered2.columns.str.replace('value', 'Recovered')"
      ],
      "execution_count": 74,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7U-Ki97KUI1V",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 139
        },
        "outputId": "d80e35f7-d3d0-4231-e9f0-3abf20697cdc"
      },
      "source": [
        "# Investigating the NULL values\n",
        "raw_data_Recovered2.isnull().sum()"
      ],
      "execution_count": 75,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "Province/State    33480\n",
              "Country/Region        0\n",
              "Lat                   0\n",
              "Long                  0\n",
              "Date                  0\n",
              "Recovered             0\n",
              "dtype: int64"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 75
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Dxuek3jaUUip",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 139
        },
        "outputId": "dd70ef8e-44c7-4272-98b4-98e013b59441"
      },
      "source": [
        "# Dealing with NULL values\n",
        "\n",
        "raw_data_confirmed2['Province/State'].fillna(raw_data_confirmed2['Country/Region'], inplace=True)\n",
        "raw_data_deaths2['Province/State'].fillna(raw_data_deaths2['Country/Region'], inplace=True)\n",
        "raw_data_Recovered2['Province/State'].fillna(raw_data_Recovered2['Country/Region'], inplace=True)\n",
        "\n",
        "raw_data_confirmed2.isnull().sum()"
      ],
      "execution_count": 76,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "Province/State    0\n",
              "Country/Region    0\n",
              "Lat               0\n",
              "Long              0\n",
              "Date              0\n",
              "Confirmed         0\n",
              "dtype: int64"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 76
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Dhss5mGUU87j",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 76,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BohynrZCWHCj",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        },
        "outputId": "7b9fbd18-74cd-407e-c655-7a680d2b4670"
      },
      "source": [
        "# printing shapes before the join\n",
        "print(\"The Shape of Cornirmed is: \", raw_data_confirmed2.shape)\n",
        "print(\"The Shape of Cornirmed is: \", raw_data_deaths2.shape)\n",
        "print(\"The Shape of Cornirmed is: \", raw_data_Recovered2.shape)"
      ],
      "execution_count": 77,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "The Shape of Cornirmed is:  (47880, 6)\n",
            "The Shape of Cornirmed is:  (47880, 6)\n",
            "The Shape of Cornirmed is:  (45540, 6)\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "pueDHbV0WXk9",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 241
        },
        "outputId": "271ce6a8-24a3-4b98-a929-97ea48f41ada"
      },
      "source": [
        "# Full Joins\n",
        "#Note:- Combined all Dataset into one\n",
        "# Confirmed with Deaths\n",
        "full_join = raw_data_confirmed2.merge(raw_data_deaths2[['Province/State','Country/Region','Date','Deaths']], \n",
        "                                      how = 'left', \n",
        "                                      left_on = ['Province/State','Country/Region','Date'], \n",
        "                                      right_on = ['Province/State', 'Country/Region','Date'])\n",
        "\n",
        "print(\"Shape of first join: \", full_join.shape)\n",
        "\n",
        "# full join with Recovered\n",
        "full_join = full_join.merge(raw_data_Recovered2[['Province/State','Country/Region','Date','Recovered']], \n",
        "                                      how = 'left', \n",
        "                                      left_on = ['Province/State','Country/Region','Date'], \n",
        "                                      right_on = ['Province/State', 'Country/Region','Date'])\n",
        "\n",
        "print(\"Shape of second join: \", full_join.shape)\n",
        "\n",
        "full_join.head()"
      ],
      "execution_count": 78,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Shape of first join:  (47880, 7)\n",
            "Shape of second join:  (47880, 8)\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>Date</th>\n",
              "      <th>Confirmed</th>\n",
              "      <th>Deaths</th>\n",
              "      <th>Recovered</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>33.93911</td>\n",
              "      <td>67.709953</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>Albania</td>\n",
              "      <td>Albania</td>\n",
              "      <td>41.15330</td>\n",
              "      <td>20.168300</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>Algeria</td>\n",
              "      <td>Algeria</td>\n",
              "      <td>28.03390</td>\n",
              "      <td>1.659600</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>Andorra</td>\n",
              "      <td>Andorra</td>\n",
              "      <td>42.50630</td>\n",
              "      <td>1.521800</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>Angola</td>\n",
              "      <td>Angola</td>\n",
              "      <td>-11.20270</td>\n",
              "      <td>17.873900</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Province/State Country/Region       Lat  ...  Confirmed Deaths  Recovered\n",
              "0    Afghanistan    Afghanistan  33.93911  ...          0      0        0.0\n",
              "1        Albania        Albania  41.15330  ...          0      0        0.0\n",
              "2        Algeria        Algeria  28.03390  ...          0      0        0.0\n",
              "3        Andorra        Andorra  42.50630  ...          0      0        0.0\n",
              "4         Angola         Angola -11.20270  ...          0      0        0.0\n",
              "\n",
              "[5 rows x 8 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 78
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "z0Rt_VmOZWWb",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 173
        },
        "outputId": "5b75c8d2-87f4-4283-a28b-7f9ed56ef758"
      },
      "source": [
        "# checking for null values (especially long and lat)\n",
        "full_join.isnull().sum()"
      ],
      "execution_count": 79,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "Province/State       0\n",
              "Country/Region       0\n",
              "Lat                  0\n",
              "Long                 0\n",
              "Date                 0\n",
              "Confirmed            0\n",
              "Deaths               0\n",
              "Recovered         2520\n",
              "dtype: int64"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 79
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mNbOiQCvZho5",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Adding Month and Year as a new Column\n",
        "full_join['Month-Year'] = full_join['Date'].dt.strftime('%b-%Y')"
      ],
      "execution_count": 80,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "iEL7WVe8cTag",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "ls COVID-19/csse_covid_19_data/csse_covid_19_daily_reports"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "wQKPtJJnZuRZ",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "345e37ac-2a2c-46d2-c598-b46fb776bde0"
      },
      "source": [
        "# Setting my path\n",
        "path = \"COVID-19/csse_covid_19_data/csse_covid_19_daily_reports\"\n",
        "\n",
        "# Changing my CWD\n",
        "os.chdir(path)\n",
        "\n",
        "df_list = []\n",
        "for file in os.listdir():\n",
        "   df = pd.read_csv(file)\n",
        "   df_list.append(df)\n",
        "   final_df = pd.concat(df_list)\n",
        "\n",
        "print(\"The shape of final df is: \", final_df.shape)"
      ],
      "execution_count": 94,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "The shape of final df is:  (417432, 19)\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0Z5k5cX5cq_E",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 282
        },
        "outputId": "8dff157b-1547-46b7-a78d-14c7171e1e39"
      },
      "source": [
        "final_df.head(4)"
      ],
      "execution_count": 95,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Last Update</th>\n",
              "      <th>Confirmed</th>\n",
              "      <th>Deaths</th>\n",
              "      <th>Recovered</th>\n",
              "      <th>Latitude</th>\n",
              "      <th>Longitude</th>\n",
              "      <th>FIPS</th>\n",
              "      <th>Admin2</th>\n",
              "      <th>Province_State</th>\n",
              "      <th>Country_Region</th>\n",
              "      <th>Last_Update</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long_</th>\n",
              "      <th>Active</th>\n",
              "      <th>Combined_Key</th>\n",
              "      <th>Incidence_Rate</th>\n",
              "      <th>Case-Fatality_Ratio</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>Mainland China</td>\n",
              "      <td>1/22/2020 17:00</td>\n",
              "      <td>1.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>Beijing</td>\n",
              "      <td>Mainland China</td>\n",
              "      <td>1/22/2020 17:00</td>\n",
              "      <td>14.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>Chongqing</td>\n",
              "      <td>Mainland China</td>\n",
              "      <td>1/22/2020 17:00</td>\n",
              "      <td>6.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>Fujian</td>\n",
              "      <td>Mainland China</td>\n",
              "      <td>1/22/2020 17:00</td>\n",
              "      <td>1.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Province/State  Country/Region  ... Incidence_Rate  Case-Fatality_Ratio\n",
              "0          Anhui  Mainland China  ...            NaN                  NaN\n",
              "1        Beijing  Mainland China  ...            NaN                  NaN\n",
              "2      Chongqing  Mainland China  ...            NaN                  NaN\n",
              "3         Fujian  Mainland China  ...            NaN                  NaN\n",
              "\n",
              "[4 rows x 19 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 95
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "SizxpKdseK4r",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 244
        },
        "outputId": "ea32daa8-57a4-46ac-f52c-8c96d4460850"
      },
      "source": [
        "\n",
        "#############################################################################################\n",
        "######################## Braking the numbers by Day #########################################\n",
        "#############################################################################################\n",
        "\n",
        "# filtering data to Anhui to give you an example\n",
        "\n",
        "#creating a new df    \n",
        "test = full_join[full_join['Province/State'] == 'Anhui']\n",
        "\n",
        "#creating a new df    \n",
        "full_join2 = test.copy()\n",
        "full_join2['Date - 1'] = full_join2['Date'] + pd.Timedelta(days=1)\n",
        "#creating a new date columns - 1\n",
        "\n",
        "full_join2.rename(columns={'Confirmed': 'Confirmed - 1', 'Deaths': 'Deaths - 1', 'Recovered': 'Recovered - 1',\n",
        "                          'Date': 'Date Minus 1'}, inplace=True)\n",
        "\n",
        "#Joing on the 2 DFs\n",
        "full_join3 = test.merge(full_join2[['Province/State', 'Country/Region','Confirmed - 1', 'Deaths - 1', \n",
        "                            'Recovered - 1', 'Date - 1', 'Date Minus 1']], how = 'outer',\n",
        "                             left_on = ['Province/State','Country/Region','Date'], \n",
        "                             right_on = ['Province/State', 'Country/Region','Date - 1'])\n",
        "\n",
        "# Additional Calculations\n",
        "full_join3['Confirmed Daily'] = full_join3['Confirmed'] - full_join3['Confirmed - 1']\n",
        "\n",
        "\n",
        "test.head()\n",
        "full_join2.head()\n",
        "full_join3.head()"
      ],
      "execution_count": 103,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>Date</th>\n",
              "      <th>Confirmed</th>\n",
              "      <th>Deaths</th>\n",
              "      <th>Recovered</th>\n",
              "      <th>Month-Year</th>\n",
              "      <th>Confirmed - 1</th>\n",
              "      <th>Deaths - 1</th>\n",
              "      <th>Recovered - 1</th>\n",
              "      <th>Date - 1</th>\n",
              "      <th>Date Minus 1</th>\n",
              "      <th>Confirmed Daily</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>1.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-23</td>\n",
              "      <td>9.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>1.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>2020-01-23</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>8.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-24</td>\n",
              "      <td>15.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>9.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>2020-01-24</td>\n",
              "      <td>2020-01-23</td>\n",
              "      <td>6.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-25</td>\n",
              "      <td>39.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>15.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>2020-01-25</td>\n",
              "      <td>2020-01-24</td>\n",
              "      <td>24.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-26</td>\n",
              "      <td>60.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>39.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>2020-01-26</td>\n",
              "      <td>2020-01-25</td>\n",
              "      <td>21.0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Province/State Country/Region  ...  Date Minus 1  Confirmed Daily\n",
              "0          Anhui          China  ...           NaT              NaN\n",
              "1          Anhui          China  ...    2020-01-22              8.0\n",
              "2          Anhui          China  ...    2020-01-23              6.0\n",
              "3          Anhui          China  ...    2020-01-24             24.0\n",
              "4          Anhui          China  ...    2020-01-25             21.0\n",
              "\n",
              "[5 rows x 15 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 103
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7kW3XvRWf8XZ",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 206
        },
        "outputId": "7004f17e-f3b6-414a-8e62-cb6b6e54ef7f"
      },
      "source": [
        "test.head()"
      ],
      "execution_count": 104,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>Date</th>\n",
              "      <th>Confirmed</th>\n",
              "      <th>Deaths</th>\n",
              "      <th>Recovered</th>\n",
              "      <th>Month-Year</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>49</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>315</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-23</td>\n",
              "      <td>9</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>581</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-24</td>\n",
              "      <td>15</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>847</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-25</td>\n",
              "      <td>39</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1113</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-26</td>\n",
              "      <td>60</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "     Province/State Country/Region      Lat  ...  Deaths Recovered  Month-Year\n",
              "49            Anhui          China  31.8257  ...       0       0.0    Jan-2020\n",
              "315           Anhui          China  31.8257  ...       0       0.0    Jan-2020\n",
              "581           Anhui          China  31.8257  ...       0       0.0    Jan-2020\n",
              "847           Anhui          China  31.8257  ...       0       0.0    Jan-2020\n",
              "1113          Anhui          China  31.8257  ...       0       0.0    Jan-2020\n",
              "\n",
              "[5 rows x 9 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 104
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vHj9Nviif8va",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 206
        },
        "outputId": "60db7426-d1bd-40d9-fcf1-fcd5eb743997"
      },
      "source": [
        "full_join2.head()"
      ],
      "execution_count": 105,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>Date Minus 1</th>\n",
              "      <th>Confirmed - 1</th>\n",
              "      <th>Deaths - 1</th>\n",
              "      <th>Recovered - 1</th>\n",
              "      <th>Month-Year</th>\n",
              "      <th>Date - 1</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>49</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>2020-01-23</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>315</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-23</td>\n",
              "      <td>9</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>2020-01-24</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>581</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-24</td>\n",
              "      <td>15</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>2020-01-25</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>847</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-25</td>\n",
              "      <td>39</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>2020-01-26</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1113</th>\n",
              "      <td>Anhui</td>\n",
              "      <td>China</td>\n",
              "      <td>31.8257</td>\n",
              "      <td>117.2264</td>\n",
              "      <td>2020-01-26</td>\n",
              "      <td>60</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>2020-01-27</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "     Province/State Country/Region  ...  Month-Year   Date - 1\n",
              "49            Anhui          China  ...    Jan-2020 2020-01-23\n",
              "315           Anhui          China  ...    Jan-2020 2020-01-24\n",
              "581           Anhui          China  ...    Jan-2020 2020-01-25\n",
              "847           Anhui          China  ...    Jan-2020 2020-01-26\n",
              "1113          Anhui          China  ...    Jan-2020 2020-01-27\n",
              "\n",
              "[5 rows x 10 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 105
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7nEXo8djf_oW",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "274afaef-6ac0-4d6d-f980-ad9132172e35"
      },
      "source": [
        "#############################################################################################\n",
        "######################## Braking the numbers by Day #########################################\n",
        "#############################################################################################\n",
        "\n",
        "## Applying it on all dataset\n",
        "\n",
        "#creating a new df    \n",
        "full_join2 = full_join.copy()\n",
        "\n",
        "#creating a new date columns - 1\n",
        "full_join2['Date - 1'] = full_join2['Date'] + pd.Timedelta(days=1)\n",
        "full_join2.rename(columns={'Confirmed': 'Confirmed - 1', 'Deaths': 'Deaths - 1', 'Recovered': 'Recovered - 1',\n",
        "                          'Date': 'Date Minus 1'}, inplace=True)\n",
        "\n",
        "#Joing on the 2 DFs\n",
        "full_join3 = full_join.merge(full_join2[['Province/State', 'Country/Region','Confirmed - 1', 'Deaths - 1', \n",
        "                            'Recovered - 1', 'Date - 1', 'Date Minus 1']], how = 'left',\n",
        "                             left_on = ['Province/State','Country/Region','Date'], \n",
        "                             right_on = ['Province/State', 'Country/Region','Date - 1'])\n",
        "\n",
        "#minus_onedf.rename(columns={'Confirmed': 'Confirmed - 1', 'Deaths': 'Deaths - 1', 'Recovered': 'Recovered - 1'}, inplace=True)\n",
        "\n",
        "full_join3.head()\n",
        "\n",
        "# Additional Calculations\n",
        "full_join3['Confirmed Daily'] = full_join3['Confirmed'] - full_join3['Confirmed - 1']\n",
        "full_join3['Deaths Daily'] = full_join3['Deaths'] - full_join3['Deaths - 1']\n",
        "full_join3['Recovered Daily'] = full_join3['Recovered'] - full_join3['Recovered - 1']\n",
        "\n",
        "print(full_join3.shape)"
      ],
      "execution_count": 106,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "(47880, 17)\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8oCYsNhrgUdh",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 261
        },
        "outputId": "b0e248d6-0955-4ef5-cfc9-667c71c085f6"
      },
      "source": [
        "full_join3.head()"
      ],
      "execution_count": 107,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>Date</th>\n",
              "      <th>Confirmed</th>\n",
              "      <th>Deaths</th>\n",
              "      <th>Recovered</th>\n",
              "      <th>Month-Year</th>\n",
              "      <th>Confirmed - 1</th>\n",
              "      <th>Deaths - 1</th>\n",
              "      <th>Recovered - 1</th>\n",
              "      <th>Date - 1</th>\n",
              "      <th>Date Minus 1</th>\n",
              "      <th>Confirmed Daily</th>\n",
              "      <th>Deaths Daily</th>\n",
              "      <th>Recovered Daily</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>33.93911</td>\n",
              "      <td>67.709953</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>Albania</td>\n",
              "      <td>Albania</td>\n",
              "      <td>41.15330</td>\n",
              "      <td>20.168300</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>Algeria</td>\n",
              "      <td>Algeria</td>\n",
              "      <td>28.03390</td>\n",
              "      <td>1.659600</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>Andorra</td>\n",
              "      <td>Andorra</td>\n",
              "      <td>42.50630</td>\n",
              "      <td>1.521800</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>Angola</td>\n",
              "      <td>Angola</td>\n",
              "      <td>-11.20270</td>\n",
              "      <td>17.873900</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaT</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Province/State Country/Region  ...  Deaths Daily  Recovered Daily\n",
              "0    Afghanistan    Afghanistan  ...           NaN              NaN\n",
              "1        Albania        Albania  ...           NaN              NaN\n",
              "2        Algeria        Algeria  ...           NaN              NaN\n",
              "3        Andorra        Andorra  ...           NaN              NaN\n",
              "4         Angola         Angola  ...           NaN              NaN\n",
              "\n",
              "[5 rows x 17 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 107
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lQZJb0s1gYV7",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 104
        },
        "outputId": "a8b2b59d-aa39-48e6-b564-fc43d6dad982"
      },
      "source": [
        "\n",
        "\n",
        "# Additing manually the numbers for first day\n",
        "\n",
        "full_join3['Confirmed Daily'].loc[full_join3['Date'] == '2020-01-22'] = full_join3['Confirmed']\n",
        "full_join3['Deaths Daily'].loc[full_join3['Date'] == '2020-01-22'] = full_join3['Deaths']\n",
        "full_join3['Recovered Daily'].loc[full_join3['Date'] == '2020-01-22'] = full_join3['Recovered']\n",
        "\n",
        "# deleting columns\n",
        "del full_join3['Confirmed - 1']\n",
        "del full_join3['Deaths - 1']\n",
        "del full_join3['Recovered - 1']\n",
        "del full_join3['Date - 1']\n",
        "del full_join3['Date Minus 1']\n",
        "\n"
      ],
      "execution_count": 110,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py:671: SettingWithCopyWarning: \n",
            "A value is trying to be set on a copy of a slice from a DataFrame\n",
            "\n",
            "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
            "  self._setitem_with_indexer(indexer, value)\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sL42c4bmg2iX",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Creating additional slicer for easy of use\n",
        "\n",
        "full_join3['Hubei Vs Rest of the World'] = 'Rest of the World'\n",
        "full_join3['Hubei Vs Rest of the World'].loc[full_join3['Province/State'] == 'Hubei'] = 'Hubei - Virus birth'\n",
        "\n",
        "#full_join3[full_join3['Province/State'] == 'Hubei']"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "kcZlzasog_ak",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 467
        },
        "outputId": "63c76add-8cab-41f0-b08d-627ab81cee9b"
      },
      "source": [
        "full_join3.head()"
      ],
      "execution_count": 112,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Province/State</th>\n",
              "      <th>Country/Region</th>\n",
              "      <th>Lat</th>\n",
              "      <th>Long</th>\n",
              "      <th>Date</th>\n",
              "      <th>Confirmed</th>\n",
              "      <th>Deaths</th>\n",
              "      <th>Recovered</th>\n",
              "      <th>Month-Year</th>\n",
              "      <th>Confirmed Daily</th>\n",
              "      <th>Deaths Daily</th>\n",
              "      <th>Recovered Daily</th>\n",
              "      <th>Hubei Vs Rest of the World</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>Afghanistan</td>\n",
              "      <td>33.93911</td>\n",
              "      <td>67.709953</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Rest of the World</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>Albania</td>\n",
              "      <td>Albania</td>\n",
              "      <td>41.15330</td>\n",
              "      <td>20.168300</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Rest of the World</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>Algeria</td>\n",
              "      <td>Algeria</td>\n",
              "      <td>28.03390</td>\n",
              "      <td>1.659600</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Rest of the World</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>Andorra</td>\n",
              "      <td>Andorra</td>\n",
              "      <td>42.50630</td>\n",
              "      <td>1.521800</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Rest of the World</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>Angola</td>\n",
              "      <td>Angola</td>\n",
              "      <td>-11.20270</td>\n",
              "      <td>17.873900</td>\n",
              "      <td>2020-01-22</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Jan-2020</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>Rest of the World</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "  Province/State Country/Region  ...  Recovered Daily  Hubei Vs Rest of the World\n",
              "0    Afghanistan    Afghanistan  ...              0.0           Rest of the World\n",
              "1        Albania        Albania  ...              0.0           Rest of the World\n",
              "2        Algeria        Algeria  ...              0.0           Rest of the World\n",
              "3        Andorra        Andorra  ...              0.0           Rest of the World\n",
              "4         Angola         Angola  ...              0.0           Rest of the World\n",
              "\n",
              "[5 rows x 13 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 112
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ds4YyYgliYNA",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "cc05bc06-7647-447a-d544-d2726b7befc6"
      },
      "source": [
        "ls"
      ],
      "execution_count": 117,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "'CoronaVirus PowerBI Raw'   \u001b[0m\u001b[01;34mCOVID-19\u001b[0m/   Data_source.ipynb\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6uME-2MPiaeu",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "4fd98061-f160-42dd-b93f-b8eedff2f1a6"
      },
      "source": [
        "cd ../.."
      ],
      "execution_count": 115,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/content/gdrive/My Drive/covd-19\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "81bGoC3liMPU",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "\n",
        "# Exporting the data\n",
        "full_join3.to_csv('CoronaVirus PowerBI Raw.csv', sep='\\t')"
      ],
      "execution_count": 118,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "RbyloTUDijTN",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "outputId": "7b7e16f1-a791-44da-cc0a-1455a5f88ed5"
      },
      "source": [
        "ls"
      ],
      "execution_count": 119,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "'CoronaVirus PowerBI Raw'       \u001b[0m\u001b[01;34mCOVID-19\u001b[0m/\n",
            "'CoronaVirus PowerBI Raw.csv'   Data_source.ipynb\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DQozLSELkpb7",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}